<?php
/**
 * Created by leiying
 * Date: 2017/11/21
 * Time: 11:44
 */
//积分
include_once(GZ_PATH . '/includes/common_func.php');
include_once(GZ_PATH . '/includes/integral_func.php');
class integralAction extends Action
{


    /**我的-积分
     * @author leiying
     */
    public function integral_index(){
        GZ_Api::authToken();
        $uid = _POST("user_id", 0);

        //获取用户总积分
        $data["user_integral"] = get_user_integral($uid);

        //获取最新的5条收支明细
        $sql = "SELECT change_desc,change_time,change_type,user_integral FROM ".$GLOBALS['db']->table("user_account")." WHERE `user_id`=".$uid." AND change_action IN('sign_in','cumulative','price_ded','poundage_ded') ORDER BY change_time desc LIMIT 5";
        $data["detail_list"] = $this->getAll($sql);

        foreach($data["detail_list"] as &$v){
            $v["change_time"] = date("Y-m-d H:i:s",$v["change_time"]);
        }
        GZ_Api::outPut($data);
    }

    /**积分收支明细-分页显示
     * @author leiying
     */
    public function integral_detail(){
        GZ_Api::authToken();
        $uid = _POST("user_id", 0);
        $page_size   = GZ_Api::$pagination['count'];    //分页设置
        $page        = GZ_Api::$pagination['page'];     //分页设置
        $res = get_integral_detail($uid,$page,$page_size);
        GZ_Api::outPut($res);
    }

}
